package com.my;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by YJH on 2017/7/13 23:03.
 */
public class TestServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setAttribute("requestKey", "requestValue666");
//        request.getRequestDispatcher("/test.jsp").forward(request, response);   //转发（一个请求）
        response.sendRedirect("test.jsp");  //重定向（两个请求）
    }
}
